package com.kandinfo.isbnmanage.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;

import com.kandinfo.base.common.repository.BaseRepository;
import com.kandinfo.isbnmanage.domian.IsbnInformation;

public interface IsbnInformationRepository extends BaseRepository<IsbnInformation, Long> {

	@Query(value = "select count(1) from isbn_information where barcode = ?1" , nativeQuery = true)
	Integer getCountByBarcode(String barcode);

	@Query(value = "select count(1) from isbn_information where barcode = ?1 and status = ?2" , nativeQuery = true)
	Integer getCountByBarcodeAndStatus(String barcode, Integer status);
	
	@Query(value = "select * from isbn_information where barcode = ?1" , nativeQuery = true)
	List<IsbnInformation> findByBarcode(String barcode);
	
	@Query(value = "select * from isbn_information where barcode = ?1 and id = ?2" , nativeQuery = true)
	List<IsbnInformation> findByBarcodeAndInforId(String barcode, Long isbnInformationId);

	@Query(value = "select * from isbn_information where id = ?1" , nativeQuery = true)
	IsbnInformation findInforByInforId(Long isbnInformationId);

	@Query(value = "select * from isbn_information where barcode = ?1 and status != 5 " , nativeQuery = true)
	List<IsbnInformation> findUnDropListByBarcode(String barcode);
}
